package com.into.common.csv;

/**
 * Works as a factory in a chain of responsibility manner to return the fields
 * to be serialized on an object
 * 
 * @author Zied Hamdi
 * 
 */
public interface CSVFieldsDefiner {
	/**
	 * returns the csv fields definitions with converters
	 * 
	 * @param serializable
	 * @return
	 */
	public CSVField<?>[] getCSVFields(String[] values);

	/**
	 * Analyses content and returns an empty corresponding instance to hold that
	 * data
	 * 
	 * @param values
	 * @return
	 */
	public Object createInstance(String[] values);

	/**
	 * returns the CSVFields for the current java instance (to write it to csv)
	 * 
	 * @param toPersist
	 *            the current instance to persist
	 * @return the columns definitions to persist for <code>toPersist</code>
	 */
	public CSVField<?>[] getCSVFields(Object toPersist);

}
